<template>
<div>
  <Drawer title="选择应用场景进入装户图" width="600" :closable="false" @on-close="close" v-model="moduleModal">
<!--    <Card class="cardclassStyle" ref="aaaaa" v-for="(item,index) in moduleList" :key="index">-->
<!--      <p slot="title">-->
<!--        {{ item.name }}-->
<!--      </p>-->
<!--      <CellGroup v-for="(item1,index1) in item.children" :key="index1" >-->
<!--        <Cell style="height: 40px" :disabled="item1.is_click==='1'">-->
<!--          <div slot="label">-->
<!--            {{item1.name}}-->
<!--&lt;!&ndash;            <img v-if="item1.img1" :src="item1.img1" style="width: 15px;height: 15px" slot="label"/>&ndash;&gt;-->
<!--            <span v-if="item1.is_click==='0' && item1.second_level_id !==undefined && item1.second_level_id !==''">{{item1.focusgroupUserNum}} 人</span>-->
<!--          </div>-->
<!--          <Button type="primary" slot="extra" shape="circle" icon="ios-search" :disabled="item1.is_click==='1'" @click="pickModule(item1)"></Button>-->
<!--        </Cell>-->
<!--      </CellGroup>-->
<!--    </Card>-->
    <div class="container-drawer">
      <div v-for="(item,index) in moduleList" :key="index" >
        <Card v-if="item.is_show === '0' " class="cardclassStyle">
          <p slot="title">
            {{ item.name }}
          </p>
          <CellGroup v-for="(item1,index1) in item.children" :key="index1" >
            <Cell style="height: 40px">
              <div slot="label">
                {{item1.name}}
                <img v-show="item1.label_img" :src="item1.label_img" width="30" height="30">
                <span style="margin-left: 5px" v-if="item1.pid !==undefined && item1.id !=='' && item1.labelNum !== undefined">{{item1.labelNum}} 人</span>
              </div>
              <Button type="primary" slot="extra" shape="circle" icon="ios-search" @click="pickModule(item1)"></Button>
            </Cell>
          </CellGroup>
        </Card>
      </div>
    </div>

  </Drawer>
  <grid-person-new ref="gridPersonNew"></grid-person-new>
</div>
</template>

<script>
import {
  findLabelListNew
  // findModuleList
} from '../../../../api/eventlist'
import GridPersonNew from './grid-person-new'

export default {
  name: 'grid-module',
  components: { GridPersonNew },
  data () {
    return {
      moduleModal: false,
      result: {},
      moduleList: []
    }
  },
  mounted () {

  },
  methods: {
    close () {
      this.$nextTick(() => {
        const ivuDrawerBody = document.querySelector('.container-drawer')
        ivuDrawerBody.scrollTop = 0
      })
    },
    // init (e) {
    //   this.moduleModal = true
    //   this.result = e
    //   let data = {
    //     building_id: this.result.id
    //   }
    //   findModuleList(data).then(ret => {
    //     if (ret.data.errcode === 0) {
    //       this.moduleList = ret.data.data
    //     } else {
    //       this.$Notice.error({
    //         title: '查询失败',
    //         desc: ret.data.errmsg
    //       })
    //     }
    //   })
    // },
    init (e) {
      this.moduleModal = true
      this.result = e
      let data = {
        building_id: this.result.id
      }
      findLabelListNew(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.moduleList = ret.data.data
          let data = {
            name: '装户图',
            is_show: '0',
            children: [
              {
                name: '装户图',
                is_show: '0'
              }
            ]
          }
          this.moduleList.unshift(data)
          this.moduleList.forEach(item => {
            if (item.id === 'L006') {
              let x = item.children
              console.log(x)
              // eslint-disable-next-line no-unused-vars
              let y = {}
              let z = []
              x.forEach(item1 => {
                console.log(item1.label)
                if (item1.id !== 'L006-1622614288234') {
                  z.push(item1)
                } else {
                  y = item1
                }
              })
              z.unshift(y)
              item.children = z
            }
          })
        } else {
          this.$Notice.error({
            title: '查询失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    pickModule (e) {
      let data = {
        buildingInfo: this.result,
        moduleInfo: e
      }
      console.log('pickModule', data)
      this.$refs.gridPersonNew.init(data)
    }
  }
}
</script>

<style scoped>
.cardClass{
  width: 100px;
  height: 100px;
  /*background-color: #F1F1F4;*/
  text-align: center;
  padding-top: 15%;
  /*line-height: 60px*/
}
.rowClass{
  background:#eee;
  padding-left:20px;
  padding-top:20px;
  padding-right:20px
}
.colClass{
  margin-bottom: 20px;
}
.cardclassStyle{
  width:100%;
  margin-bottom: 20px
}
/deep/.ivu-drawer-body{
  overflow-y: auto!important;
}
.container-drawer{
  height: 100%;
  overflow-y: auto;
}
</style>
